#ifndef BACKEND_H
#define BACKEND_H

#include <QObject>
//单例模式
class Backend : public QObject
{
    Q_OBJECT
public:
    explicit Backend(QObject *parent = nullptr);
    static Backend* instance(){
        if(m_instance == nullptr){
            m_instance = new Backend();
        }
        return m_instance;
    }
    Q_INVOKABLE void receive(const QString &msg); //接收前端消息

signals:
    void message(QString msg); //信号发送消息给前端

private:
    static Backend* m_instance;
};


class Backend2 : public QObject
{
    Q_OBJECT
public:
    explicit Backend2(QObject *parent = nullptr);

    Q_INVOKABLE void receive(const QString &msg); //接收前端消息

signals:
    void message(QString msg); //信号发送消息给前端

private:
    static Backend* m_instance;
};
//Backend与Backend2后端类中的receive函数实现把接收到的前端消息返回给前端
#endif // BACKEND_H
